package com.atguigu.gmall.pms.api;

import com.atguigu.gmall.common.bean.PageParamVo;
import com.atguigu.gmall.common.bean.ResponseVo;
import com.atguigu.gmall.pms.entity.*;
import com.atguigu.gmall.pms.vo.ItemGroupVo;
import com.atguigu.gmall.pms.vo.ItemSkuAttrsVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

public interface PmsApi {
    @ApiOperation("查询属性分组和组内的spu的属性以及制定sku的属性集合")
    @GetMapping("pms/attrgroup/queryGroupAndAttrValues")
    public ResponseVo<List<ItemGroupVo>>queryGroupAndAttrValues(
            @RequestParam(value = "cid",required = true)String c3id,
            @RequestParam(value = "spuId",required = true)String spuId,
            @RequestParam(value = "skuId",required = true)String skuId );
    @ApiOperation("查询spu的所有的sku 每个sku销售属性值和 skuid映射的json字符串")
    @GetMapping("pms/skuattrvalue/querySkusSaleAttrsJson/{spuId}")
    public ResponseVo<String> querySkusSaleAttrsJson(@PathVariable("spuId")String spuId);
    @ApiOperation("查询sku的销售属性值 和 attrId映射的map")
    @GetMapping("pms/skuattrvalue/querySkuSaleAttr/{skuId}")
    public ResponseVo<Map<Long , String>>  querySkuSaleAttr(@PathVariable("skuId")String skuId);
    @ApiOperation("查询spu下所有的sku的销售属性和值的集合")
    @GetMapping("pms/skuattrvalue/queryItemSkuAttrsVoBySpuId/{spuId}")
    public ResponseVo<List<ItemSkuAttrsVo>> queryItemSkuAttrsVoBySpuId(@PathVariable("spuId")
                                                                               String spuId);
    @GetMapping("pms/spudesc/{spuId}")
    @ApiOperation("详情查询")
    public ResponseVo<SpuDescEntity> querySpuDescById(@PathVariable("spuId") Long spuId);
    @ApiOperation("根据skuid查询图片集合")
    @GetMapping("pms/skuimages/querySkuImagesBySkuId/{skuId}")
    public ResponseVo<List<SkuImagesEntity>> querySkuImagesBySkuId(@PathVariable("skuId")
                                                                           String skuId);
    @ApiOperation("根据3级分类id查询3、2、1级分类对象集合")
    @GetMapping("pms/category/queryLevel123Cates/{c3id}")
    public ResponseVo<List<CategoryEntity>> queryLevel123Cates(@PathVariable("c3id") String c3id);
    @GetMapping("pms/sku/{id}")
    @ApiOperation("sku详情查询")
    public ResponseVo<SkuEntity> querySkuById(@PathVariable("id") Long id);
    @ApiOperation("根据1级分类id查询2、3级分类集合")
    @GetMapping("pms/category/lv2AndSubsCates/{cid}")
    public ResponseVo<List<CategoryEntity>> lv2AndSubsCates(@PathVariable("cid")String cid);
    //查询指定parentId分类集合
    @GetMapping("pms/category/parent/{parentId}")
    public ResponseVo<List<CategoryEntity>> parent(@PathVariable("parentId")String parentId);
    //根据spuid查询spu
    @GetMapping("pms/spu/{id}")
    @ApiOperation("详情查询")
    public ResponseVo<SpuEntity> querySpuById(@PathVariable("id") Long id);
    /*
        该接口远程访问时，使用的请求方式是get方式，远程服务的接口接收参数时是pojo入参

        feign客户端远程访问时没有加注解的参数默认以请求体方式提交
            而且get请求报文没有请求体的，如果feign调用的方法没有加注解，默认feign会发起post方式的请求 将参数存在请求体中

        就出现405了

        解决：
            方式1： 修改请求方式 为post
            方式2： feign包提供了一个注解:@SpringQueryMap
                    可以将get方式请求时需要传递的pojo对象转为路径参数提交
     */
    @ApiOperation("search服务远程查询spu分页数据")
    @GetMapping("pms/spu/page")
    public ResponseVo<List<SpuEntity>> querySpuListByPage(@SpringQueryMap PageParamVo paramVo);//?

    @GetMapping("pms/brand/{id}")
    @ApiOperation("品牌详情查询")
    public ResponseVo<BrandEntity> queryBrandById(@PathVariable("id") Long id);

    @ApiOperation("分类详情查询")
    @GetMapping("pms/category/{id}")
    public ResponseVo<CategoryEntity> queryCategoryById(@PathVariable("id") Long id);

    @ApiOperation("search服务查询检索属性和值")
    @GetMapping("pms/spuattrvalue/spu/{spuId}")
    public ResponseVo<List<SpuAttrValueEntity>> querySpuSearchAttrValues(@PathVariable("spuId") Long spuId);
    @ApiOperation("查询spu的sku列表")
    @GetMapping("pms/sku/spu/{spuId}")
    public ResponseVo<List<SkuEntity>> querySkusBySpuId(@PathVariable("spuId")String spuId);

    @ApiOperation("search服务查询sku检索属性和值")
    @GetMapping("pms/skuattrvalue/sku/{skuId}")
    public ResponseVo<List<SkuAttrValueEntity>> querySkuSearchAttrValues(@PathVariable("skuId")Long skuId);
}